class ScorePanel {
    score: number = 0;
    level: number = 1;
    scoreEl: HTMLElement;
    levelEl: HTMLElement;

    maxLevel: number;
    Upscore: number;

    constructor(maxLevel: number = 10,Upscore:number=10){
        this.maxLevel = maxLevel;
        this.Upscore = Upscore;
        this.scoreEl = document.getElementById("score") as HTMLElement;
        this.levelEl = document.getElementById("level") as HTMLElement;
    }

    addScore(){
        this.scoreEl.innerHTML = ++this.score + '';
        if(this.score % this.Upscore ===0){
            this.levelUp();
        }       
    }

    levelUp(){
        if(this.level<this.maxLevel){
            this.levelEl.innerHTML = ++this.level + '';
        }
        
    }
}

export default ScorePanel;